
const app = getApp()

Page({

  data: {
    region: ['点击选择'],
  },

  bindRegionChange: function (e) {
    var cityInfo = {
      code:e.detail.code[2],
      region:e.detail.value
    }
    this.setData({
      region: e.detail.value,
    })
    wx.setStorageSync('cityInfo', cityInfo);
    app.globalData.cityInfo = cityInfo;
  },


  jumpPage(){
    var t = this
    if(!app.globalData.cityInfo){
      wx.showToast({
        title: '请选择地区',
        icon:'error'
      })
    }else{
      wx.switchTab({
        url: "/pages/index_info/index_info",
      })
    }
  },


  onShow() {
    var t = this
  },

  onLoad() {
    var t = this

    //判断是否有城市缓存，并显示当前城市
    if(wx.getStorageSync('cityInfo')){
      this.setData({
        region: wx.getStorageSync('cityInfo').region,
      })
      app.globalData.cityInfo = wx.getStorageSync('cityInfo')
    }
  },





})